package top.zerozoo.learn.grade.vo;

import top.zerozoo.learn.grade.entity.StudentBaseInfo;
import top.zerozoo.learn.grade.enums.Sex;

/**
 * 员工基础信息封装类
 */
public class StudentSimpleInfo {
    private Integer id;
    private String name;
    private String sex;
    private Integer age;
    private String major;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    @Override
    public String toString() {
        return "StudentSimpleInfo{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", major='" + major + '\'' +
                '}';
    }

    public static StudentSimpleInfo parse(StudentBaseInfo studentBaseInfo) {
        StudentSimpleInfo info = new StudentSimpleInfo();
        info.setId(studentBaseInfo.getId());
        info.setName(studentBaseInfo.getName());
        info.setSex(Sex.parse(studentBaseInfo.getSex()).toString());
        info.setAge(studentBaseInfo.getAge() < 0 ? 0 : studentBaseInfo.getAge());
        info.setMajor(studentBaseInfo.getDepartment());
        return info;
    }
}
